//
//  ThreeDPublishCollectionViewCell.m
//  ShrimpCrowdordering
//
//  Created by jimmy on 2018/8/25.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ThreeDPublishCollectionViewCell.h"
#import "UIView+Utils.h"

@interface ThreeDPublishCollectionViewCell()

///传入的标题的字符串
@property (nonatomic,strong)  NSArray  * titleArray;
///传入的背景图片
@property (nonatomic,strong)  NSArray  * bjImageArray;

@end

@implementation ThreeDPublishCollectionViewCell

#pragma mark  设置ThreeDPublishCollectionViewCell的内容
+ (ThreeDPublishCollectionViewCell *)cellWithCollectionView:(UICollectionView *)collectionView andIndexPath:(NSIndexPath *)indexPath andTitleArray:(NSArray *)titleArray andBjImageArray:(NSArray *)bjImageArray andCellId:(NSString *)cellId
{
//    static NSString *cellID = @"ThreeDPublishCollectionViewCell";
    ThreeDPublishCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
    
    cell.titleArray = titleArray;
    cell.bjImageArray = bjImageArray;
    
    return cell;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIView *bjView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/2-ScreenX375(5), ScreenX375(210))];
        bjView.userInteractionEnabled = YES;
        [self addSubview:bjView];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.size = CGSizeMake(ScreenX375(80), ScreenX375(14));
        self.titleLabel.centerX = SCREEN_WIDTH/4;
        self.titleLabel.top = ScreenX375(0);
        self.titleLabel.textColor = FONTCOLOR_BLACK;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = Kfont(14);
        [bjView addSubview:self.titleLabel];
        
        self.contentImageView = [[UIImageView alloc] init];
        self.contentImageView.frame = CGRectMake(ScreenX375(15), self.titleLabel.bottom + ScreenX375(8), bjView.width - ScreenX375(36), bjView.width - ScreenX375(36));
        //添加边框
        self.contentImageView.userInteractionEnabled = YES;
        CALayer * layer = [self.contentImageView layer];
        layer.borderColor = [RGBACOLOR(0, 0, 0, 0.1) CGColor];
        layer.borderWidth = 1.0f;
        //添加四个边阴影
        self.contentImageView.layer.shadowColor = RGBACOLOR(0, 0, 0, 0.1).CGColor;//阴影颜色
        self.contentImageView.layer.shadowOffset = CGSizeMake(1.0, 1.0);//偏移距离
        self.contentImageView.layer.shadowOpacity = 0.5;//不透明度
        self.contentImageView.layer.shadowRadius = 1.0;//半径
        
        self.rightImage = [[UIImageView alloc] init];
        self.rightImage.frame = CGRectMake(self.contentImageView.width-ScreenX375(25), ScreenX375(5), ScreenX375(21), ScreenX375(21));
        self.rightImage.userInteractionEnabled = YES;
        self.rightImage.image = [UIImage imageNamed:@"未选择"];
        [self.contentImageView addSubview:self.rightImage];
        
        
        self.contentLabel = [[UILabel alloc] init];
        self.contentLabel.size = CGSizeMake(self.contentImageView.width, self.contentImageView.height - ScreenX375(25));
        self.contentLabel.centerX = self.contentImageView.centerX;
        self.contentLabel.centerY = self.contentImageView.centerY;
        self.contentLabel.textColor = FONTCOLOR_BLACK;
        self.contentLabel.textAlignment = NSTextAlignmentCenter;
        self.contentLabel.font = Kfont(18);
        [self addSubview:self.contentLabel];
        
        [bjView addSubview:self.contentImageView];
    }
    return self;
}

@end
